using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using DTO;
using BUS;
using Utility;

namespace BUS
{
   public  class TinhTrang_SanPham_BUS
    {
       public static void Insert(TinhTrang_SanPham_DTO sanpham)
        {
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            sanpham_DAL.Insert(sanpham);
        }
       public static void Update(TinhTrang_SanPham_DTO sanpham)
        {
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            sanpham_DAL.Update(sanpham);
        }
        public static void Delete(int iD)
        {
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            sanpham_DAL.Delete(iD);
        }
       public static TinhTrang_SanPhamCollection Get(string where,
             int pageindex,
             int pagesize,
             string orderby,
             string orderdirection,
             out int total)
        {
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            return sanpham_DAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
       public static TinhTrang_SanPhamCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            return sanpham_DAL.Get(cri.Criter, 0, 0, TinhTrang_SanPhamColumns.MaTinhTrang_SP.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static TinhTrang_SanPham_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, TinhTrang_SanPhamColumns.MaTinhTrang_SP.ToString(), Condition.EQUAL, iD);
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            TinhTrang_SanPhamCollection sanphamCollection = sanpham_DAL.Get (cri.Criter,
                0, 0, TinhTrang_SanPhamColumns.MaTinhTrang_SP.ToString(), OrderDirection.ASC.ToString(), out total);
            if (sanphamCollection.Count > 0)
                return sanphamCollection[0];
            return null;
        }
       public static TinhTrang_SanPhamCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_SanPham_DAL sanpham_DAL = new TinhTrang_SanPham_DAL();
            return sanpham_DAL.Get(cri.Criter, 1, number,
                TinhTrang_SanPhamColumns.MaTinhTrang_SP.ToString(), OrderDirection.DESC.ToString(), out total);
        }
       public static TinhTrang_SanPhamCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrang_SanPham_DAL sanphamDAL = new TinhTrang_SanPham_DAL();
            return sanphamDAL.Get(cri.Criter, 1, number,
                TinhTrang_SanPhamColumns.MaTinhTrang_SP.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
